from pmbase import PluginBase
from glan import Lan
import os
from constants import Constant
import sys


def fmt_verstr(verstr):
    nums = verstr[1:].split(".")
    return int(nums[0]) * 100 + int(nums[1]) * 10 + int(nums[2])


class InfoPlugin(PluginBase):

    PLUGIN_INFO = dict(
        name="info",
        help="show the local info for local plugin!"
    )

    def __init__(self):
        if not hasattr(self, "_inc"):
            self._inc = super().__init__(self.PLUGIN_INFO)
        return self._inc

    def __get_plugindir(self, pluginname, isglobal=False):
        # todo global install
        pdir = os.path.join(os.getcwd(), Constant.L_PACKINSTALL_DIR)
        return os.path.join(pdir, pluginname)

    def parser_config(self, argparser):
        super().parser_config(argparser)
        argparser.add_argument("pluginname",
                               help="the plugin name to install")

    def run(self, argpars):
        super().run(argpars)
        InfoPlugin
